package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import top.soulblack.purchasesale.model.GoodsClassify;
import java.util.List;

@Mapper
@Component
public interface GoodsClassifyMapper {

    List<Integer> deleteById(Integer id);

    int deleteByPrimaryKey(Integer id);

    int insert(GoodsClassify record);

    GoodsClassify selectByPrimaryKey(Integer id);

    List<GoodsClassify> selectAll();

    int updateByPrimaryKey(GoodsClassify record);

    @Select("select distinct `remarks` from goods_classify")
    List<String> selectGroups();

    @Insert("insert into goods_classify (name, `remarks`) values (#{name}, #{remarks})")
    void addClassify(GoodsClassify goodsClassify);

    @Select("select count(*) from goods_classify where name = #{name}")
    int existClassify(String name);

    @Select("select * from goods_classify where `remarks` = #{remarks}")
    List<GoodsClassify> selectForGroup(@Param("remarks") String group);

    @Update("update goods_classify set `remarks` = #{remarks} where `group` = #{ogroup}")
    int updateGroup(@Param("ngroup") String ngroup, @Param("ogroup") String ogroup);

    @Update("update goods_classify set `group` = '' where `group` = #{ogroup}")
    int deleteGroup(@Param("ogroup") String oldGroup);

}